package com.itheima.web.controller;

import com.itheima.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

//@Controller
//@ResponseBody
@RestController//等同于@Controller+@ResponseBody联合使用
@RequestMapping("/ajax")
public class AjaxController {
    /*
     * @ResponseBody
     *   将对象转换成json格式数据
     * @RequestBody
     *   将json数据转换成对象
     * */

    @RequestMapping("/test1")
    public String test1(String username){
        System.out.println("ajax test1...");
        return username;
    }

    @RequestMapping("/test2")
    public String test2(@RequestBody String user){
        System.out.println(user);
        return "yes";
    }

    @RequestMapping("/test3")
    public String test3(User user){
        System.out.println(user);
        return "";
    }
}
